package com.jsgt.greekfire.ui.trading.adapter

import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.TextView
import com.fhx.core.base.BaseAdapter
import com.fhx.core.base.BaseViewHolder
import com.jsgt.greekfire.R
import com.jsgt.greekfire.bean.CoinBean
import com.jsgt.greekfire.ui.trading.buycoin.BuyCoinActivity

/**
 * author fhx
 * create time 2020/4/23 19:50
 **/
class TradingAdapter : BaseAdapter<CoinBean>() {

    inner class VH(itemView: View) : BaseViewHolder(itemView) {
        var id_tv: TextView? = null
        var number_tv: TextView? = null
        var trading_num_tv: TextView? = null
        var uti_tv: TextView? = null
        var buyTv: TextView? = null

        init {
            id_tv = itemView.findViewById(R.id.id_tv)
            number_tv = itemView.findViewById(R.id.number_tv)
            trading_num_tv = itemView.findViewById(R.id.trading_num_tv)
            uti_tv = itemView.findViewById(R.id.uti_tv)
            buyTv = itemView.findViewById(R.id.buy_tv)
        }

        fun bindData(coinBean: CoinBean) {
//            id_tv?.text = "ID:" + coinBean.userGuid
//            number_tv?.text = "数量 ${coinBean.totalAmt} UTI"
//            uti_tv?.text = "${coinBean.assetPrice.toString()}/UTI"
            buyTv?.setOnClickListener {
                BuyCoinActivity.start(itemView.context, coinBean)
            }
        }
    }

    override fun provideViewHolder(parent: ViewGroup, viewType: Int): BaseViewHolder? {
        val view = LayoutInflater.from(parent.context).inflate(R.layout.item_trading, parent, false)
        return VH(view)
    }

    override fun onBindViewHolder(holder: BaseViewHolder, position: Int) {
        val vh = holder as VH
        vh.bindData(dataList()[position])
    }
}